package lcr;

import java.util.ArrayDeque;

public class Test0036 {
}

class Solution0037_1 {
    public int evalRPN(String[] tokens) {
        ArrayDeque<Integer> deque = new ArrayDeque<>();
        for (String token : tokens) {
            switch (token) {
                case "+":
                    deque.push(deque.poll() + deque.poll());
                    break;
                case "-":
                    deque.push(-deque.poll() + deque.poll());
                    break;
                case "*":
                    deque.push(deque.poll() * deque.poll());
                    break;
                case "/":
                    Integer poll1 = deque.poll();
                    Integer poll2 = deque.poll();
                    deque.push(poll2 / poll1);
                    break;
                default:
                    deque.push(Integer.valueOf(token));
            }
        }
        return deque.poll();
    }
}
